package com.atguigu.day08;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class FlinkTest01 {

    public static void main(String[] args) throws Exception {

        //1.获取执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);

        //2.从端口读取数据
        DataStreamSource<String> socketTextStream = env.socketTextStream("hadoop102", 9999);

        //3.修改其并行度为2
        SingleOutputStreamOperator<String> mapDS = socketTextStream.map(line -> line).setParallelism(2);

        //4.重分区
        mapDS.broadcast().print("broadcast>>>>").setParallelism(4);
        mapDS.global().print("global>>>>").setParallelism(4);
        //mapDS.forward().print("forward>>>>>").setParallelism(4);

        //5.启动任务
        env.execute();

    }

}
